<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich">
    <h:head>
        <title>合同执行单列表</title>
        <style type="text/css"> 
            input[type='submit']{
                margin:3px 5px 3px 5px;
                padding:2px 5px 2px 5px;
            }
        </style>
    </h:head>
    <h:body>
        <rich:panel header="合同执行单列表" styleClass="content-hight">
            <h:form id="incontracts">
                <h:panelGroup  id="curTab">
                    <rich:tabPanel rendered="#{contractExecuteBean.querybut}">
                        <rich:tab  header="查询条件" >
                            <h:panelGrid columns="4">
                                <h:outputLabel value="单据编号：" for="vounumber"/>
                                <h:inputText size="23" id="vounumber" value="#{queryExecBean.vounumber}"/>
                                <h:outputLabel value="合同类型：" for="contype"/>
                                <h:inputText size="23" id="contype" value="#{queryExecBean.contype}"/>

                                <h:outputLabel value="合同代码：" for="number"/>
                                <h:inputText size="23" id="number" value="#{queryExecBean.number}"/>

                                <h:outputText value="执行日期："/>
                                <h:panelGroup>
                                    <rich:calendar value="#{queryExecBean.voudateStart}"
                                                   locale="Locale.CHINA"
                                                   popup="true"
                                                   datePattern="yyyy-MM-dd"
                                                   showApplyButton="false"  style="width:200px"/>
                                    至
                                    <rich:calendar value="#{queryExecBean.voudateEnd}"
                                                   locale="Locale.CHINA"
                                                   popup="true"
                                                   datePattern="yyyy-MM-dd"
                                                   showApplyButton="false"  style="width:200px"/>
                                </h:panelGroup>

                                <h:outputLabel value="执行内容：" for="name_detail"/>
                                <h:inputText size="23" id="name_detail" value="#{queryExecBean.name_detail}"/>

                                <h:outputLabel value="技术要求：" for="tech_detail"/>
                                <h:inputText size="23" id="tech_detail" value="#{queryExecBean.tech_detail}"/>

                                <h:outputLabel value="数量："/>
                                <h:panelGroup>
                                    <h:inputText size="20" id="countStart_detail"
                                                 value="#{queryExecBean.countStart_detail}"/>
                                    -<h:inputText size="20" id="countEnd_detail"
                                                  value="#{queryExecBean.countEnd_detail}"/>
                                </h:panelGroup>

                                <h:outputLabel value="单价："/>
                                <h:panelGroup>
                                    <h:inputText size="20" id="priceStart_detail"
                                                 value="#{queryExecBean.priceStart_detail}"/>
                                    -<h:inputText size="20" id="priceEnd_detail"
                                                  value="#{queryExecBean.priceEnd_detail}"/>
                                </h:panelGroup>

                                <h:outputLabel value="总金额："/>
                                <h:panelGroup>
                                    <h:inputText size="20" id="totalStart_detail"
                                                 value="#{queryExecBean.totalStart_detail}"/>
                                    -<h:inputText size="20" id="totalEnd_detail"
                                                  value="#{queryExecBean.totalEnd_detail}"/>
                                </h:panelGroup>

                            </h:panelGrid>
                            注：用明细筛选时，有一条符合即可。
                        </rich:tab>
                    </rich:tabPanel>
                    <a4j:commandButton value="查询" rendered="#{contractExecuteBean.querybut}"
                                       action="#{contractExecuteBean.query}"
                                       render="execGroup"/>
                    <a4j:commandButton value="取消" rendered="#{contractExecuteBean.querybut}"
                                       action="#{contractExecuteBean.queryCancel}"
                                       render="execGroup"/>
                    <a4j:commandButton value="隐藏" rendered="#{contractExecuteBean.querybut}"
                                       action="#{contractExecuteBean.hiddenbut}"
                                       render="curTab"/>
                    <a4j:commandButton value="显示" rendered="#{!contractExecuteBean.querybut}"
                                       action="#{contractExecuteBean.showbut}"
                                       render="curTab"/>
                </h:panelGroup>
                <h:panelGroup id="execGroup">
                    <rich:dataScroller for="execTable" execute="@this" render="execGroup"/>
                    <div style="overflow:auto;">
                        <rich:dataTable id="execTable"
                                        value="#{contractExecuteBean.execModel}" var="incontract"
                                        rowClasses="list-row-odd,list-row-even"
                                        headerClass="table-header" 
                                        style="width:100%;margin-bottom: 5px;"
                                        noDataLabel="无数据">

                            <a4j:ajax event="rowdblclick"
                                      execute="@this" render="detailGroup"
                                      listener="#{contractExecuteBean.rowDetail}"
                                      oncomplete="#{rich:component('detailPanel')}.show();">
                            </a4j:ajax>

                            <rich:column style="text-align: center;width:60px;">
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="单据编号"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:commandLink action="#{contractExecuteBean.execSelected}">
                                    <h:outputText value="#{incontract.vounumber}"/>
                                </h:commandLink>
                            </rich:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="合同类型"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="主合同" rendered="#{incontract.contype eq '0'}"/>
                                <h:outputText value="补充合同" rendered="#{incontract.contype eq '1'}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="合同编号"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{incontract.number}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="合同名称"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{incontract.conName}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="执行日期"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{incontract.voudate}">
                                    <f:convertDateTime dateStyle="medium"/>
                                </h:outputText>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="对方单位"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{incontract.mainInfo.partner.name}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="标的"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{incontract.mainInfo.target}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="执行金额"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{incontract.execTotal}"/>
                            </h:column>
                        </rich:dataTable>
                    </div>
                </h:panelGroup>
            </h:form>

            <rich:popupPanel id="detailPanel" autosized="true">
                <f:facet name="header">执行单明细</f:facet>
                <f:facet name="controls">
                    <h:outputLink value="#" onclick="#{rich:component('detailPanel')}.hide();">关闭</h:outputLink>
                </f:facet>
                <h:panelGroup id="detailGroup">
                    <rich:dataScroller for="exeTable" execute="@this" render="editTable"/>
                    <div style="width:600px;height:300px;overflow: auto;">
                        <rich:dataTable  id="exeTable"
                                         value="#{contractExecuteBean.detailListForShow}"
                                         var="dl"
                                         rowKeyVar="index"
                                         rows="10"
                                         noDataLabel="无数据"
                                         style="width:100%;">
                            <rich:column style="text-align:center;">
                                <h:outputText  value="#{index+1}"/>
                            </rich:column>
                            <h:column>
                                <f:facet name="header">执行内容</f:facet>
                                <h:outputText value="#{dl.name}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">技术要求</f:facet>
                                <h:outputText value="#{dl.technicrequirment}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">数量</f:facet>
                                <h:outputText value="#{dl.count}"/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">单价</f:facet>
                                <h:outputText value="#{dl.price}"/>
                            </h:column>
                            <rich:column style="width:60px">
                                <f:facet name="header">金额</f:facet>
                                <h:outputText id="total" value="#{dl.count * dl.price}"/>
                            </rich:column>
                            <h:column>
                                <f:facet name="header">备注</f:facet>
                                <h:outputText value="#{dl.memo}"/>
                            </h:column>
                        </rich:dataTable>
                    </div>
                </h:panelGroup>
            </rich:popupPanel>
        </rich:panel>
    </h:body>
</ui:composition>
